﻿<%@ Page Title="" Language="C#" MasterPageFile="../master/faa.master" AutoEventWireup="true" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<style type="text/css">  
    #fm{ margin:0; padding:10px 30px; }  
    .ftitle{ font-size:14px; font-weight:bold; padding:5px 0; margin-bottom:10px; border-bottom:1px solid #ccc; }  
    .fitem{ margin-bottom:5px; }  
    .fitem label{ display:inline-block; width:100px; }  
    .fitem input,textarea{ width:480px; }
</style>
<script type="text/javascript">
    var url;
    function newItem() {
        var row = $('#tg').datagrid('getSelected');
        if (row) {
            $('#dlg').dialog('open').dialog('setTitle', '新增基元检查内容');
            $('#fm').form('clear');
            url = '/template_faa/handler/ajax.ashx?view=jiyuanNR&action=insert&pid=' + row.jyId + '&project=' + row.jyProjectId;
        }

    }
    function editItem() {
        var row = $('#tg').datagrid('getSelected');
        if (row) {
            $('#dlg').dialog('open').dialog('setTitle', '编辑基元检查内容');
            $('#fm').form('load', row);
            url = '/template_faa/handler/ajax.ashx?view=jiyuanNR&action=update&id=' + row.jyId;
        }
    }
    function saveItem() {
        $('#fm').form('submit', {
            url: url,
            onSubmit: function() {
                return $(this).form('validate');
            },
            success: function(result) {
                var result = eval('(' + result + ')');
                if (result.errorMsg) {
                    $.messager.show({
                        title: 'Error',
                        msg: result.errorMsg
                    });
                } else {
                    $('#dlg').dialog('close');
                    $('#tg').treegrid('reload');
                    $.messager.alert('提示', '保存成功，等待管理员审核', 'info');
                }
            }
        });
    }
    function delItem() {
        var row = $('#tg').datagrid('getSelected');
        if (row) {
            $.messager.confirm('提示', '您确认要删除这条基元检查内容吗？', function(r) {
                if (r) {
                    $.post('/template_faa/handler/ajax.ashx?view=jiyuanNR&action=delete', { id: row.jyId }, function(result) {
                        if (result.errorMsg) {
                            $.messager.show({
                                title: 'Error',
                                msg: result.errorMsg
                            });
                        } else {
                            $('#tg').treegrid('reload');
                        }
                    }, 'json');
                }
            });
        }
    }
    
    function toggleTemp() {
        $('#tg').treegrid({ url: '/template_faa/handler/treegrid.ashx',
            queryParams: { showTemp: 'yes', view: 'jiyuanNR', project: '<%=Context.Request["project"] %>' }
        });
    }
</script>  
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="body" runat="server">
    <div class="clear  wide" id="bodyPadding">
        <!--左侧导航栏-->
        <div id="vNav">
            <ul class="Sle S2">
                <li>
                    <h4>基元信息</h4>
                    <ul>
                        <li><a class="here" href="jiyuanXM.aspx">浏览基元项目</a></li>
                    </ul>
                </li>
            </ul>
            <ul class="Sle S2">
                <li>
                    <h4>管理基元库</h4>
                    <ul>
                        <li><a href="jiyuanXMSH.aspx">审核基元项目</a></li>
                        <li><a href="jiyuanNRSH.aspx">审核基元内容</a></li>
                    </ul>
                </li>
            </ul>
        </div>
        
        <!--右上快速链接栏-->
        <div class="clear" id="breadcrumbs">
            <p>
                <a href="#">基元系统</a> <span>»</span> <a href="#">基元项目</a> <span>»</span> 添加基元项目
            </p>
        </div>
        
        <!--右下主体栏-->
        <div class="whiteSheet">
            <div class="content" id="content_01">
	            <h1 class="pageTitle">基元信息查看</h1>
	            <div class="demo-info">
		            <div class="demo-tip icon-tip"></div>
		            <div>查看基元内容，点击左侧箭头可以收起和展开</div>
	            </div>
	            <div id="tb" style="padding:5px;height:auto">  
                    <div style="margin-bottom:5px">  
                        <table cellpadding="0" cellspacing="0" style="width: 100%">
                            <tr>
                                <td>
                                    <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="newItem()">新增下一级</a>  
                                    <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="editItem()">编辑</a>  
                                    <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="delItem()">删除</a>  
                                </td>
                                <td style="text-align: right">
                                    <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-reload" plain="true" onclick="toggleTemp()">显示临时检查内容</a>  
                                </td>
                            </tr>
                        </table>
                    </div>  
                </div>  
                <table id="tg" title="基元检查内容 " class="easyui-treegrid" style="width:780px;height:800px" toolbar="#tb"
                        data-options="  
                            url: '/template_faa/handler/treegrid.ashx?view=jiyuanNR&project=<%=Context.Request["project"] %>',
                            rownumbers: false,  
                            pagination: false,  
                            pageSize: 2,  
                            pageList: [2,10,20],  
                            idField: 'jyId',  
                            treeField: 'jyName',
                            rowStyler: function(row){
                                if (row.jyIsTempVar > 0) {
                                    return 'background-color:#FF6600;color:#fff;font-weight:bold;';
                                }
                            },
                            onBeforeLoad: function(row,param){  
                                if (!row) { // load top level rows  
                                    param.id = 0;   // set id=0, indicate to load new page rows  
                                }  
                            },
                            onLoadSuccess: function(data){
                                // $('#tg').treegrid('collapseAll');
                            }
                        ">  
                    <thead>  
                        <tr>  
				            <th field="jyName" width="160" editor="text">检查内容</th>
				            <th field="jyContent" width="60" editor="text">检查方法</th>
				            <th field="jyStandard" width="200" editor="text">检查标准</th>
				            <th field="jyBasis" width="100" editor="text">依据</th>
				            <th field="jyPenalizeRef" width="80" editor="text" >处罚参考</th>
				            <th field="jyCreateDate" width="80" editor="text">创建日期</th>
				            <th field="jyIsMust" width="60" editor="text">必选项目</th>
				            <th field="jyProjectId" width="80" editor="text" hidden="true">隐藏</th>
				            <th field="jyParentId" width="80" editor="text" hidden="true">隐藏</th>
				            <th field="jyIsTempVar" width="80" editor="text" hidden="true">隐藏</th>
				            <th field="jyIsTemp" width="80" editor="text" hidden="true">隐藏</th>
                        </tr>  
                    </thead>  
                </table>  

                <div id="dlg" class="easyui-dialog" style="width:600px;height:420px;padding:10px 20px"  
                    closed="true" buttons="#dlg-buttons">  
                <div class="ftitle">请输入基元内容的详细信息</div>  
                    <form id="fm" method="post" novalidate>  
                        <div class="fitem">  
                            <label>检查内容：</label><br />
                            <input name="jyName" class="easyui-validatebox" required="true">
                        </div>  
                        <div class="fitem">  
                            <label>检查标准：</label><br />  
                            <textarea name="jyStandard" class="easyui-validatebox"></textarea>  
                        </div>  
                        <div class="fitem">  
                            <label>检查方法：</label><br />  
                            <input name="jyContent" class="easyui-validatebox">  
                        </div>  
                        <div class="fitem">  
                            <label>依据：</label><br />  
                            <input name="jyBasis" class="easyui-validatebox">  
                        </div>  
                        <div class="fitem">  
                            <label>处罚参考：</label><br />  
                            <input name="jyPenalizeRef" class="easyui-validatebox">  
                        </div>  
                        <div class="fitem">  
                            <label>是否必选：</label><br />  
                            <input class="easyui-combobox" name="jyIsMust" style="width:200px;" data-options="
                                valueField:'value', textField:'text', panelHeight:'auto',
                                data: [{ text: '是', value: '1', selected:true }, { text: '否', value: '0' }]
                            ">
                        </div>  

                    </form>  
                </div>  
                <div id="dlg-buttons">  
                    <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-ok" 
                        onclick="saveItem()">保存</a>  
                    <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" 
                        onclick="javascript:$('#dlg').dialog('close')">取消</a>  
                </div>

            </div>
        </div>
    </div>
    
</asp:Content>
